
using Core.SimpleTemp.Common;
using Core.SimpleTemp.Entitys;
using Core.SimpleTemp.Repositories.Internal;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
//using Core.SimpleTemp.Repository.RepositoryEntityFrameworkCore.Internal;
namespace Core.SimpleTemp.Repositories.RepositoryEntityFrameworkCore.Sys
{
    [AutoDi()]//注意这里 自动DI
    public class SysDepartmentDutyRepository : BaseDBRepository<SysDepartmentDuty>
    //统一继承BaseDBRepository并传入`Entity`泛型参数
    {
        public SysDepartmentDutyRepository(CoreDBContext dbContext) : base(dbContext)
        {
        }

        /// <summary>
        /// 根据部门id获取职务
        /// </summary>
        /// <returns></returns> 
        public Task<List<SysDepartmentDuty>> GetDutyListBySysDepartmentIDAsync(Guid SysDepartmentID)
        {
            //var sysDepartDuty = _dbContext.Set<SysDepartmentDuty>().Where(sd => sd.SysDepartmentID == SysDepartmentID).AsNoTracking();
            //var innerJoin = from sdd in _dbContext.Set<SysDepartmentDuty>()
            //                join sd in _dbContext.Set<SysDepartment>() on sdd.SysDepartmentID equals sd.Id
            //                join sdt in _dbContext.Set<SysDuty>() on sdd.SysDutyID equals sdt.Id
            //                where sdd.SysDepartmentID == SysDepartmentID && sdt.CreateFactory == sd.CreateFactory && sdt.IsDeleted == false
            //                select new 
            //                {
            //                    DepartmentName = sd.Name,
            //                    DutyName = sdt.Name,
            //                    sd.CreateFactory,
            //                    sd.Code,
            //                    DepartmentId = sd.Id,
            //                    DutyId = sdt.Id
            //                };
            //return innerJoin.ToListAsync();
            return null;
        }
    }
}
